Skip to content

refactor(reborn): extract ironclaw_reborn_http_kit (1/N — composition decomposition)#5137

Draft
serrrfirat wants to merge 4 commits into
mainfrom
reborn/composition-decomposition
Draft

refactor(reborn): extract ironclaw_reborn_http_kit (1/N — composition decomposition)#5137
serrrfirat wants to merge 4 commits into
mainfrom
reborn/composition-decomposition

Conversation

@serrrfirat

Copy link
Copy Markdown
Collaborator

Draft. First of an incremental series decomposing the ironclaw_reborn_composition god-crate (~132k lines), one isolated crate per PR so each lands fast before main diverges. This PR extracts the foundational, product-agnostic HTTP middleware kit. Supersedes the stale big-bang draft #5135.

Why incremental

ironclaw_reborn_composition has grown to ~132k lines by accreting product/service domains (Slack, product-auth, LLM-admin, extension/MCP) plus a generic HTTP middleware kit behind cfg-gated features. The full decomposition design was ratified by a two-model design council — see docs/plans/2026-06-21-composition-crate-decomposition.md. An earlier branch did all six extractions at once but went stale against 168 commits of parallel development on the same crate. This series lands them one crate at a time.

This PR: extract ironclaw_reborn_http_kit

Two tightly-coupled, behavior-preserving steps:

1. Invert the route-mount seam. webui_serve no longer hardcodes product route families. The serving core is now product-agnostic compose_webui_v2_app(api, config); products supply generic ProtectedRouteMount / PublicRouteMount fragments via WebuiServeConfig::with_{protected,public}_route_mount. ProtectedRouteMount::operator_gated(...) reproduces the Slack channel-routes admin gating generically. The product-aware lowering (turning bundle.product_auth into mounts) moved to webui.rs, which wraps the core. The Slack route factories now return the generic mount types.

2. Extract the crate. The six descriptor-driven middleware modules move out of composition into the new crate:

ironclaw_reborn_composition/src/webui_serve.rs        → http_kit/src/serve.rs
                            webui_body_limit.rs        →         body_limit.rs
                            webui_rate_limit.rs        →         rate_limit.rs
                            webui_route_match.rs       →         route_match.rs
                            webui_ws_origin.rs         →         ws_origin.rs
                            webui_operator_auth.rs     →         operator_auth.rs

ironclaw_reborn_http_kit depends only on substrate (ironclaw_auth, ironclaw_host_api, ironclaw_product_workflow, ironclaw_webui_v2(+static)) — zero product knowledge. Composition re-exports the same public symbols via pub use ironclaw_reborn_http_kit::…, so reborn_cli, reborn_webui_ingress, and all downstream paths compile unchanged.

Verification (green)

Check Result
ironclaw_reborn_http_kit tests 24 passed, 0 failed
ironclaw_reborn_http_kit clippy (all features) zero warnings
ironclaw_reborn_composition test-compile (all features) 0 errors
ironclaw_reborn_composition clippy (all features) zero warnings
runtime:: suite serial (--test-threads=1) 134 passed, 0 failed
ironclaw_reborn_webui_ingress (all features) 170 passed, 0 failed
ironclaw_architecture boundary tests 37 passed, 0 failed
cargo fmt, reborn_cli build clean / ✅

Note on parallel flakiness: the full composition suite shows a few non-deterministic failures in runtime::tests under parallel load (a different set each run). These are pre-existing on main — several local_dev_runtime_* / nearai tests share process-global state (env vars for the nearai session token, OS keychain, temp files) and race under high parallelism. They pass deterministically when run serially (134/134 above) and in isolation, and this PR only touches the webui HTTP middleware — orthogonal to nearai/runtime bootstrapping. Flagging as a pre-existing test-isolation issue, not introduced here.

Next in the series

product_authslack_hostllm_adminextension_host, plus relocating the OutboundDeliveryTargetProvider vocabulary into ironclaw_product_workflow (the Slack-cycle prerequisite). Each a separate, individually-verified PR.

🤖 Generated with Claude Code

First of an incremental series decomposing the ~132k-line
ironclaw_reborn_composition god-crate, one isolated crate per PR.

Two behavior-preserving steps:
- Invert the route-mount seam: webui_serve's serving core becomes the
  product-agnostic `compose_webui_v2_app(api, config)`; products supply
  generic ProtectedRouteMount/PublicRouteMount fragments. The
  product-auth lowering moves to webui.rs; Slack route factories return
  the generic mount types. `ProtectedRouteMount::operator_gated` keeps
  the channel-routes admin gating.
- Extract crates/ironclaw_reborn_http_kit: the 6 descriptor-driven
  middleware modules (serve/body_limit/rate_limit/route_match/ws_origin/
  operator_auth) move out of composition into a substrate-only crate with
  zero product knowledge. Composition re-exports the same public symbols
  via `pub use`, so reborn_cli / reborn_webui_ingress compile unchanged.

Verified: http_kit 24 tests + clippy clean; composition test-compiles
all-features + clippy clean; runtime:: suite 134/134 serial; ingress
170; ironclaw_architecture boundary tests 37; reborn_cli builds.

Design doc: docs/plans/2026-06-21-composition-crate-decomposition.md

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 60165bb0-3d8f-4490-80fa-199cb3e500a2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@railway-app railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-5137 June 22, 2026 15:56 Destroyed
@github-actions github-actions Bot added size: XL 500+ changed lines scope: docs Documentation scope: dependencies Dependency updates risk: medium Business logic, config, or moderate-risk modules contributor: core 20+ merged PRs and removed size: XL 500+ changed lines labels Jun 22, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request extracts the HTTP middleware and routing utilities from ironclaw_reborn_composition into a new standalone crate, ironclaw_reborn_http_kit. This includes modules for body limits, operator authentication, rate limiting, route matching, and WebSocket origin enforcement. Downstream modules and tests have been updated to use this new crate. The review feedback points out that intra-doc links to compose_webui_v2_app in body_limit.rs and ws_origin.rs may fail to resolve because the function is not imported in those modules, and suggests using the fully qualified path crate::compose_webui_v2_app instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

//! rejected without spending a bearer-validation step.
//! - It runs **after** the outer `RequestBodyLimitLayer` global cap
//! that [`crate::webui_serve::webui_v2_app`] keeps as a defense in
//! that [`compose_webui_v2_app`] keeps as a defense in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The intra-doc link [compose_webui_v2_app] may fail to resolve because compose_webui_v2_app is not imported in this module. Specifying the full path [crate::compose_webui_v2_app] ensures that rustdoc can resolve the link correctly.

Suggested change
//! that [`compose_webui_v2_app`] keeps as a defense in
//! that [`crate::compose_webui_v2_app`] keeps as a defense in

//! declare a [`WebSocketOriginPolicy`] other than `NotApplicable`.
//!
//! The CORS layer composed by [`crate::webui_serve::webui_v2_app`]
//! The CORS layer composed by [`compose_webui_v2_app`]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The intra-doc link [compose_webui_v2_app] may fail to resolve because compose_webui_v2_app is not imported in this module. Specifying the full path [crate::compose_webui_v2_app] ensures that rustdoc can resolve the link correctly.

Suggested change
//! The CORS layer composed by [`compose_webui_v2_app`]
//! The CORS layer composed by [`crate::compose_webui_v2_app`]

@railway-app

railway-app Bot commented Jun 22, 2026

Copy link
Copy Markdown

🚅 Deployed to the ironclaw-pr-5137 environment in ironclaw-ci-preview

Service Status Web Updated (UTC)
ironclaw ✅ Success (View Logs) Web Jun 24, 2026 at 7:29 pm

@railway-app railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-5137 June 23, 2026 08:29 Destroyed
@github-actions github-actions Bot added the size: XL 500+ changed lines label Jun 23, 2026
@railway-app railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-5137 June 23, 2026 08:50 Destroyed
…roach

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@henrypark133

Copy link
Copy Markdown
Collaborator

⚠️ Attention — file overlap with an in-flight bugfix.

A branch in progress (fix/reborn-run-wait-class) modifies crates/ironclaw_reborn_composition/src/openai_compat_serve.rs: it bounds the unbounded wait_for_response_completion loop that currently hangs the HTTP handler forever when a run parks on an approval/auth gate, and makes response_status_from_projection_run_status an exhaustive typed match (no _ => None).

Since this refactor relocates that file, can we coordinate landing order? The bugfix is intentionally surgical — happy to rebase it after this lands, or land the fix first if that's easier for the decomposition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: medium Business logic, config, or moderate-risk modules scope: dependencies Dependency updates scope: docs Documentation size: XL 500+ changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants